package com.Jasper.controller;

import com.Jasper.domain.Test;
import com.Jasper.service.TestService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName TestContrller
 * @Author jiangjiajia
 * @JDK-Version 1.8
 * @Date 2021/8/31 2:57 pm
 * @Version 1.0
 * @Description 必须描述类的业务用途
 **/

@RestController
@ComponentScan("com.Jasper")
@RequestMapping("/test")
public class TestContrller {


    @Resource
    private TestService testService;


    /**
     * 取出配置文件中配置项  TEST是默认配置值
     */
    @Value("${test.hello:TEST}")
    private String testHello;


    @GetMapping("/hello")
    public String hello(){
        return "Hello World"+  testHello;
    }

    @PostMapping("/hello/post")
    public String helloPost(String name) {
        return "Hello World! Post，" + name;
    }

    @GetMapping("/list")
    public List<Test> list() {
        return testService.list();
    }

}
